package com.sanyuan.cloud.module.system.controller.app.appauth;

import com.sanyuan.cloud.framework.apilog.core.annotation.ApiAccessLog;
import com.sanyuan.cloud.framework.common.pojo.CommonResult;
import com.sanyuan.cloud.module.system.annotation.AddGroup;
import com.sanyuan.cloud.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import com.sanyuan.cloud.module.system.controller.app.appauth.req.AppAuthReqVO;
import com.sanyuan.cloud.module.system.service.appauth.AppAuthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

import static com.sanyuan.cloud.framework.common.pojo.CommonResult.success;

/**
 * @Description:
 * @Author: wuyuwei
 * @Date: 2025/3/21
 */
@Tag(name = "小程序 - 认证")
@RestController
@RequestMapping("/system/auth")
public class AppAuthController {

    @Resource
    private AppAuthService appAuthService;

    @ApiAccessLog
    @PostMapping("/weixinMiniAppLogin")
    @Operation(summary = "微信小程序登录")
    @PermitAll
    public CommonResult<AuthLoginRespVO> weixinMiniAppLogin(@RequestBody @Validated(AddGroup.class) AppAuthReqVO reqVO) {
        return success(appAuthService.login(reqVO));
    }
}
